<%--<%@ page import="com.lengmou.service.TypeService" %>--%>
<%--<%@ page import="com.lengmou.service.impl.TypeServiceImpl" %>--%>
<%@ page import="com.lengmou.entity.Goods" %>
<%--<%@ page import="com.lengmou.entity.Type" %>--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" trimDirectiveWhitespaces="true"  %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<% String path = request.getContextPath(); %>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="apple-mobile-web-app-title" content="">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="renderer" content="webkit">
    <meta name="viewport" content="width=1200">
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="icon" href="http://masadora-js.masadora.net/static/new_masadora/images/favicon/masadora-icon.png">
    <link rel="apple-touch-icon" href="http://masadora-js.masadora.net/static/new_masadora/images/favicon/masadora-icon.png">
    <link rel="apple-touch-icon-precomposed" href="http://masadora-js.masadora.net/static/new_masadora/images/favicon/masadora-icon.png">
    <script src="<%=path%>/js/jquery-3.1.0.js" ></script>
    <script>
        $(function () {

            $('a[action="删除搜索字段"]').click(function () {
                $("#keyword").val("");
            });
        });
    </script>
    <title>商品列表</title>
</head>

<body>


<%--插入头部--%>

<%@include file="header.jsp" %>

<div class="bg-gray">
<form method="get" action="search" class="func-list-search-box">
    <div class="ui-layout">
        <input id="keyword" type="text" name="name" placeholder="请输入搜索的商品名称" autocomplete="off" autofocus="autofocus" value="${name}">
        <button type="submit">搜索</button>
        <a action="删除搜索字段"></a>
    </div>
</form>
</div>
    <div class="ui-layout">
        <div class="ui-crumb-box">
            <b><a href="/">首页</a></b>
            <i></i>
            <a href=""></a>
        </div>
        <div class="view-good-filter-box">
            <div class="filter-item-box">
                <b>类型</b>
                <c:choose>
                    <c:when test="${type!=null&&type.length()!=0}">
                        <a data-id="${type}" href="search?name=${name}&up=${up}">全部</a>
                    </c:when>
                    <c:otherwise>
                        <a href="#" class="active">全部</a>
                    </c:otherwise>
                </c:choose>
                <c:forEach items="${types}" var="t">
                    <c:choose>
                        <c:when test="${t.id==type}">
                            <a class="active" href="#" >${t.name}</a>
                        </c:when>
                        <c:otherwise>
                            <a href="search?type=${t.id}&name=${name}&up=${up}&down=${down}" >${t.name}</a>
                        </c:otherwise>
                    </c:choose>
                </c:forEach>
            </div>
            <div class="filter-item-box">
                <b>排序</b>
                <!--<a href="/product/search?size=64&sort=&categoryId=&keyword=&propertyBrand_id=&propertySeries_id=&saleStatus=&saleType=" data-sort="hot">人气</a>-->
                <c:if test="${up==null&&down==null}">
                    <a href="search?type=${type}&name=${name}" class="active">默认</a>
                    <a href="search?type=${type}&name=${name}&up=1" data-sort="price">价格</a>
                </c:if>
                <c:if test="${up!=null&&up==1}">
                    <a href="search?type=${type}&name=${name}">默认</a>
                    <a href="search?type=${type}&name=${name}&down=1" data-sort="price" class="active" data-sort-type="asc">价格</a>
                </c:if>
                <c:if test="${down!=null&&down==1}">
                    <a href="search?type=${type}&name=${name}">默认</a>
                    <a href="search?type=${type}&name=${name}&up=1" data-sort="price" class="active" data-sort-type="desc">价格</a>
                </c:if>
            </div>
        </div>
        <div class="ui-good-list-box">
            <%--这里开始商品--%>
            <c:choose>
                <c:when test="${goodsList!=null&&goodsList.size()>0}">
                    <c:forEach items="${goodsList}"  var="goods">
                        <%--<%--%>
                            <%--TypeService ts = new TypeServiceImpl();--%>
                            <%--Goods goods = (Goods) pageContext.getAttribute("goods");--%>
                            <%--Type type = ts.queryTypeById(goods.getType());--%>
                            <%--pageContext.setAttribute("tp",type);--%>
                        <%--%>--%>
                        <a class="ui-good-item"  href="info?goodsid=${goods.id}">
                            <div class="cover-box">
                                <img src="<%=path%>/${goods.img}">
                            </div>
                            <div class="info-box">
                                <h4>${goods.name}</h4>
                                <span class="price">${goods.price}</span>
                                <div class="tags-box">
                                    <span>信息</span>
                                </div>
                            </div>
                        </a>
                    </c:forEach>
                </div>
                    <div class="ui-page">
                        <!-- <a href="" class="first"></a> -->
                        <a href="search?pageNum=${pageInfo.prePage}&type=${type}&name=${name}&ud=${ud}" class="prev">上页</a>
                        <c:forEach items="${pageInfo.navigatepageNums}" var="num">
                            <c:choose>
                                <c:when test="${num==pageInfo.pageNum||pageInfo.pageNum==0&&num==1}">
                                    <a href="#" class="active">${num}</a>
                                </c:when>
                                <c:otherwise>
                                    <a href="search?pageNum=${num}&type=${type}&name=${name}&up=${up}&down=${down}">${num}</a>
                                </c:otherwise>
                            </c:choose>
                        </c:forEach>
                            <%--<span></span>--%>
                        <a href="search?pageNum=${pageInfo.nextPage}&type=${type}&name=${name}&up=${up}&down=${down}" class="next">下页</a>
                        <!-- <a href="" class="end"></a> -->
                    </div>
                </c:when>
                <c:otherwise>
                    <div class="func-error-box">
                        <h1 class="big">不存在该商品</h1>
                        <h1>抱歉，您要的我们给不了</h1>
                        <p>虽然这个商品不存在了，但其实您可以继续看看:</p>
                        <div class="ctrl-box">
                            <a href="index" class="btn min stroke">访问首页</a>
                            <a href="user" class="btn min stroke black">个人中心</a>
                        </div>
                    </div>
                </c:otherwise>
            </c:choose>

    </div>
<div id="page_end_html">
    <script src="https://cdn.jsdelivr.net/npm/live2d-widget@3.0.4/lib/L2Dwidget.min.js"></script>
    <script type="text/javascript">
        L2Dwidget.init();
    </script>
</div>
<%@include file="foot.jsp"%>
</body>
</html>

